<!DOCTYPE html>
<html>
<head th:include="common/header_css::header('霸王餐小程序后台管理-商品信息','%mfile%datepicker')"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div th:replace="common/toolbar::toolbar('商家应用管理')"></div>
        <div th:replace="common/search::search('%add')"></div>
        <!-- End Panel Basic -->
    </div>

    <!--添加MerchantApp模态框-->
    <div id="modal-add-form" class="modal fade" aria-hidden="true">
        <div class="modal-dialog" style="width: 800px;">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row">
                        <h3 class="m-t-none m-b">商家分店应用信息添加</h3>
                        <div class="col-sm-12">
                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    <form id="aform" method="post" class="form-horizontal" action="add"
                                          onsubmit="return checkAdd()">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">应用名*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="name" required type="text"
                                                               maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">实体店ID</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="sid" type="number"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">Appid*</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="appid" required type="text"
                                                               maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">Appsecret*</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="appsecret" required
                                                               type="text" maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">应用编码</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="mpcode" type="text" required
                                                               maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支付类型*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="payType">
                                                            <option value="1">微信支付</option>
                                                            <option value="2">支付宝支付</option>
                                                            <option value="3">百度支付</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">应用类型</label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="appType">
                                                            <option value="1">微信公众号</option>
                                                            <option value="2">微信小程序</option>
                                                            <option value="3">微信授权APP</option>
                                                            <option value="4">支付宝小程序</option>
                                                            <option value="5">百度小程序</option>
                                                            <option value="6">头条小程序</option>
                                                            <option value="7">新浪微博</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">应用版本</label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="version">
                                                            <option value="1">基础版</option>
                                                            <option value="2">专业版</option>
                                                            <option value="3">行业版</option>
                                                            <option value="4">平台版</option>
                                                            <option value="5">3DVR版</option>
                                                            <option value="6">旗舰版</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">商户ID</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="mchid" type="text"
                                                               maxlength="32"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支付密钥</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="paykey"
                                                               type="text" maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">客服电话1</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="kefu1" type="text"
                                                               maxlength="12"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">客服电话2</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" name="kefu2" type="text"
                                                               maxlength="12"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">应用logo</label>
                                                    <div class="col-sm-10">
                                                        <input id="mfile" name="mfile" type="file" class="file"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">公众号二维码</label>
                                                    <div class="col-sm-10">
                                                        <input id="mfilegzhimg" name="mfile" type="file" class="file"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">客服二维码</label>
                                                    <div class="col-sm-10">
                                                        <input id="mfilekefuimg" name="mfile" type="file" class="file"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-4 col-sm-offset-2">
                                                <button class="btn btn-primary" type="submit">保存内容</button>
                                                <button data-toggle="modal" type="button" class="btn btn-white"
                                                        href="#modal-add-form">取消
                                                </button>
                                            </div>
                                        </div>
                                        <input id="hidpic" name="pic" type="hidden" value="" />
                                        <input id="hidgzhimg" name="gzhimg" type="hidden" value="" />
                                        <input id="hidkefuimg" name="kefuimg" type="hidden" value="" />
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!--修改MerchantApp模态框-->
    <div id="modal-form" class="modal fade" aria-hidden="true">
        <div class="modal-dialog" style="width: 800px;">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row">
                        <h3 class="m-t-none m-b">商家分店应用信息修改</h3>
                        <div class="col-sm-12">
                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    <form id="mform" method="post" class="form-horizontal" action="modify"
                                          onsubmit="return checkModify()">
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">应用名*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="name" name="name" required
                                                               type="text" maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">商家分店ID</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="sid" name="sid"
                                                               type="number"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">Appid*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="appid" name="appid"
                                                               required
                                                               type="text" maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">AppSecret*</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="appsecret" name="appsecret"
                                                               required
                                                               type="text" maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支付商户ID</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="mchid" name="mchid"
                                                               type="text" maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支付密钥</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="paykey" name="paykey"
                                                               type="text" maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">应用编码*</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="mpcode" name="mpcode"
                                                               type="text" readonly
                                                               maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">支付类型*
                                                    </label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="payType" id="payType">
                                                            <option value="1">微信支付</option>
                                                            <option value="2">支付宝支付</option>
                                                            <option value="3">百度支付</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">应用类型</label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="appType" id="appType">
                                                            <option value="1">微信公众号</option>
                                                            <option value="2">微信小程序</option>
                                                            <option value="3">微信授权APP</option>
                                                            <option value="4">支付宝小程序</option>
                                                            <option value="5">百度小程序</option>
                                                            <option value="6">头条小程序</option>
                                                            <option value="7">新浪微博</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">应用版本</label>
                                                    <div class="col-sm-8">
                                                        <select class="form-control" name="version" id="version">
                                                            <option value="1">基础版</option>
                                                            <option value="2">专业版</option>
                                                            <option value="3">行业版</option>
                                                            <option value="4">平台版</option>
                                                            <option value="5">3DVR版</option>
                                                            <option value="6">旗舰版</option>
                                                            <option value="7">大众名片版</option>
                                                            <option value="8">商家名片版</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">客服电话1</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="kefu1" name="kefu1"
                                                               type="text" maxlength="20"/>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-6">
                                                <div class="form-group">
                                                    <label class="col-sm-4 control-label">客服电话2</label>
                                                    <div class="col-sm-8">
                                                        <input class="form-control" id="kefu2" name="kefu2"
                                                               type="text" maxlength="50"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">应用logo</label>
                                                    <div class="col-sm-10">
                                                        <input id="mfile2" name="mfile" type="file" class="file"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">公众号二维码</label>
                                                    <div class="col-sm-10">
                                                        <input id="mfilegzhimg2" name="mfile" type="file" class="file"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-12">
                                                <div class="form-group">
                                                    <label class="col-sm-2 control-label">客服二维码</label>
                                                    <div class="col-sm-10">
                                                        <input id="mfilekefuimg2" name="mfile" type="file" class="file"/>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-4 col-sm-offset-2">
                                                <button class="btn btn-primary" type="submit">保存内容</button>
                                                <button data-toggle="modal" type="button" class="btn btn-white"
                                                        href="#modal-form">取消
                                                </button>
                                            </div>
                                        </div>
                                        <input id="hidpic2" name="pic" type="hidden" value=""/>
                                        <input id="hidgzhimg2" name="gzhimg" type="hidden" value=""/>
                                        <input id="hidkefuimg2" name="kefuimg" type="hidden" value="" />
                                        <input id="id" name="id" type="hidden" value=""/>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="cloneapp-form" class="modal fade" aria-hidden="true">
        <div class="modal-dialog" style="width: 800px;">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">克隆目标应用</label>
                                <div class="col-sm-10">
                                    <select class="form-control select2" id="targetmpid" name="targetmpid">
                                        <option th:each="c:${mapps}" th:value="${c.id}" th:text="${c.name}"></option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row" style="margin-top: 20px">
                        <div class="col-sm-4 col-sm-offset-2">
                            <button class="btn btn-primary" type="button" onclick="clone()">克隆</button>
                            <button data-toggle="modal" type="button" class="btn btn-white" href="#cloneapp-form">取消
                            </button>
                            <input id="hidmpid" name="mpid" type="hidden" value=""/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div id="payfile-form" class="modal fade" aria-hidden="true">
        <div class="modal-dialog" style="width: 800px;">
            <div class="modal-content">
                <div class="modal-body">
                    <form action="/admin/merchantapp/uploadPayfile" method="post" enctype="multipart/form-data" onsubmit="return checkPayfile()">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">上传支付密钥</label>
                                    <div class="col-sm-10">
                                        <input id="payfile" type="file" name="mfile"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row" style="margin-top: 20px">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">提交</button>
                                <button data-toggle="modal" type="button" class="btn btn-white" href="#payfile-form">取消</button>
                                <input id="hidmpid2" name="tid" type="hidden" value=""/>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <div th:include="common/footer_js::footer"></div>
    <script src="/js/admin/merchantapp.js"></script>
    <input id="isAdmin" type="hidden" th:value="${isAdmin}"/>
</body>
</html>
<script th:inline="javascript">
    var pwd = [[${pwd}]], idu = [[${idu}]];
    if (idu && idu.length > 0) {
        swal({title: "商家信息提示", text: "新创建【商家应用登陆账号】为：" + idu + "\n\r" + "【商家应用登陆密码】为：" + pwd, type: "success"})
    }
</script>
